<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1999-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Extensions to namelist (The GNU Fortran Compiler)</title>

<meta name="description" content="Extensions to namelist (The GNU Fortran Compiler)">
<meta name="keywords" content="Extensions to namelist (The GNU Fortran Compiler)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran" rel="up" title="Extensions implemented in GNU Fortran">
<link href="X-format-descriptor-without-count-field.html#X-format-descriptor-without-count-field" rel="next" title="X format descriptor without count field">
<link href="Old_002dstyle-variable-initialization.html#Old_002dstyle-variable-initialization" rel="prev" title="Old-style variable initialization">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<a name="Extensions-to-namelist"></a>
<div class="header">
<p>
Next: <a href="X-format-descriptor-without-count-field.html#X-format-descriptor-without-count-field" accesskey="n" rel="next">X format descriptor without count field</a>, Previous: <a href="Old_002dstyle-variable-initialization.html#Old_002dstyle-variable-initialization" accesskey="p" rel="prev">Old-style variable initialization</a>, Up: <a href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran" accesskey="u" rel="up">Extensions implemented in GNU Fortran</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Extensions-to-namelist-1"></a>
<h4 class="subsection">5.1.3 Extensions to namelist</h4>
<a name="index-Namelist"></a>

<p>GNU Fortran fully supports the Fortran 95 standard for namelist I/O
including array qualifiers, substrings and fully qualified derived types.
The output from a namelist write is compatible with namelist read.  The
output has all names in upper case and indentation to column 1 after the
namelist name.  Two extensions are permitted:
</p>
<p>Old-style use of &lsquo;<samp>$</samp>&rsquo; instead of &lsquo;<samp>&amp;</samp>&rsquo;
</p><div class="smallexample">
<pre class="smallexample">$MYNML
 X(:)%Y(2) = 1.0 2.0 3.0
 CH(1:4) = &quot;abcd&quot;
$END
</pre></div>

<p>It should be noted that the default terminator is &lsquo;<samp>/</samp>&rsquo; rather than
&lsquo;<samp>&amp;END</samp>&rsquo;.
</p>
<p>Querying of the namelist when inputting from stdin.  After at least
one space, entering &lsquo;<samp>?</samp>&rsquo; sends to stdout the namelist name and the names of
the variables in the namelist:
</p><div class="smallexample">
<pre class="smallexample"> ?

&amp;mynml
 x
 x%y
 ch
&amp;end
</pre></div>

<p>Entering &lsquo;<samp>=?</samp>&rsquo; outputs the namelist to stdout, as if
<code>WRITE(*,NML = mynml)</code> had been called:
</p><div class="smallexample">
<pre class="smallexample">=?

&amp;MYNML
 X(1)%Y=  0.000000    ,  1.000000    ,  0.000000    ,
 X(2)%Y=  0.000000    ,  2.000000    ,  0.000000    ,
 X(3)%Y=  0.000000    ,  3.000000    ,  0.000000    ,
 CH=abcd,  /
</pre></div>

<p>To aid this dialog, when input is from stdin, errors send their
messages to stderr and execution continues, even if <code>IOSTAT</code> is set.
</p>
<p><code>PRINT</code> namelist is permitted.  This causes an error if
<samp>-std=f95</samp> is used.
</p><div class="smallexample">
<pre class="smallexample">PROGRAM test_print
  REAL, dimension (4)  ::  x = (/1.0, 2.0, 3.0, 4.0/)
  NAMELIST /mynml/ x
  PRINT mynml
END PROGRAM test_print
</pre></div>

<p>Expanded namelist reads are permitted.  This causes an error if
<samp>-std=f95</samp> is used.  In the following example, the first element
of the array will be given the value 0.00 and the two succeeding
elements will be given the values 1.00 and 2.00.
</p><div class="smallexample">
<pre class="smallexample">&amp;MYNML
  X(1,1) = 0.00 , 1.00 , 2.00
/
</pre></div>

<p>When writing a namelist, if no <code>DELIM=</code> is specified, by default a
double quote is used to delimit character strings. If -std=F95, F2003,
or F2008, etc, the delim status is set to &rsquo;none&rsquo;.  Defaulting to
quotes ensures that namelists with character strings can be subsequently
read back in accurately.
</p>
<hr>
<div class="header">
<p>
Next: <a href="X-format-descriptor-without-count-field.html#X-format-descriptor-without-count-field" accesskey="n" rel="next">X format descriptor without count field</a>, Previous: <a href="Old_002dstyle-variable-initialization.html#Old_002dstyle-variable-initialization" accesskey="p" rel="prev">Old-style variable initialization</a>, Up: <a href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran" accesskey="u" rel="up">Extensions implemented in GNU Fortran</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
